package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MystockValueW;
import com.ruoyi.system.service.IMystockValueWService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 每周股票价格Controller
 * 
 * @author ruoyi
 * @date 2023-03-04
 */
@RestController
@RequestMapping("/system/w")
public class MystockValueWController extends BaseController
{
    @Autowired
    private IMystockValueWService mystockValueWService;

    /**
     * 查询每周股票价格列表
     */
    @PreAuthorize("@ss.hasPermi('system:w:list')")
    @GetMapping("/list")
    public TableDataInfo list(MystockValueW mystockValueW)
    {
        startPage();
        List<MystockValueW> list = mystockValueWService.selectMystockValueWList(mystockValueW);
        return getDataTable(list);
    }

    /**
     * 导出每周股票价格列表
     */
    @PreAuthorize("@ss.hasPermi('system:w:export')")
    @Log(title = "每周股票价格", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MystockValueW mystockValueW)
    {
        List<MystockValueW> list = mystockValueWService.selectMystockValueWList(mystockValueW);
        ExcelUtil<MystockValueW> util = new ExcelUtil<MystockValueW>(MystockValueW.class);
        util.exportExcel(response, list, "每周股票价格数据");
    }

    /**
     * 获取每周股票价格详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:w:query')")
    @GetMapping(value = "/{tsCode}")
    public AjaxResult getInfo(@PathVariable("tsCode") String tsCode)
    {
        return success(mystockValueWService.selectMystockValueWByTsCode(tsCode));
    }

    /**
     * 新增每周股票价格
     */
    @PreAuthorize("@ss.hasPermi('system:w:add')")
    @Log(title = "每周股票价格", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MystockValueW mystockValueW)
    {
        return toAjax(mystockValueWService.insertMystockValueW(mystockValueW));
    }

    /**
     * 修改每周股票价格
     */
    @PreAuthorize("@ss.hasPermi('system:w:edit')")
    @Log(title = "每周股票价格", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MystockValueW mystockValueW)
    {
        return toAjax(mystockValueWService.updateMystockValueW(mystockValueW));
    }

    /**
     * 删除每周股票价格
     */
    @PreAuthorize("@ss.hasPermi('system:w:remove')")
    @Log(title = "每周股票价格", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tsCodes}")
    public AjaxResult remove(@PathVariable String[] tsCodes)
    {
        return toAjax(mystockValueWService.deleteMystockValueWByTsCodes(tsCodes));
    }
}
